<template lang="html">
  <section class="components-index_list-index" :class="{ event: isEventList }">
    <div class="topline"></div>

    <!-- 活动列表 -->
    <template v-for="courseDetail in courseList" v-if="isEventList">
      <header class="eventDetail-header">
        <span>{{courseDetail.area}}</span>
        <span>{{courseDetail.dateStr}}</span>
      </header>
      <EventItem
        :eventDetail="courseDetail"
        v-if="courseDetail.is_activity == '1'">
     </EventItem>
    </template>
    <!-- 课程列表 -->
    <template v-for="(courseBlock, key) in courseList" v-if="!isEventList">
      <!-- 某区域的课程 -->
      <div class="index_list-courseBlock" v-if="(currentDistrictId == 0 || key == currentDistrictId )&& courseBlock.store.length > 0">
        <header class="courseBlock-header">
          <span>{{courseBlock.name}}</span>
          <!-- <span>{{courseBlock.dateStr}}</span> -->
        </header>
        <template v-for="courseDetail in courseBlock.store">
          <EventItem
            :eventDetail="courseDetail"
            :isShowDate="false"
             v-if="courseDetail && courseDetail.is_activity == '1'"
          >
          </EventItem>
          <CourseItem
            :courseDetail="courseDetail"
            :isShowDate="false"
            v-if="courseDetail && courseDetail.is_activity != '1' && (currentCategoryId == 0 || courseDetail.categoryId == currentCategoryId)"
          >
          </CourseItem>
        </template>
      </div>
    </template>

    <!-- 列表为空时的提示 -->
    <aside class="eventNotice" v-if="isEventList && courseList.length == 0">
      <span>精彩活动</span>
      <span>敬请期待</span>
    </aside>
    <aside class="courseNotice" v-if="isEmptyCourseList">
      <i class="icon-time"></i>
      <p class="text-left">
        <span class="subtext">coming soon</span>
        <span class="maintext">我们正在策划更多精彩课程 ......</span>
      </p>
      <p class="text-right">
        <span>敬请期待</span>
      </p>
    </aside>
  </section>
</template>

<script>
export default {
  props: {
    courseList: {
      // type: Array,
      required: true
    },
    currentCategoryId: {
      type: Number,
      default: 0,
      required: true
    },
    currentDistrictId: {
      type: Number,
      default: 0,
      required: true
    }
  },
  computed: {
    isEventList(){
      return this.courseList && Object.prototype.toString.call(this.courseList) === '[object Array]'
    },
    isEmptyCourseList(){
      if(this.isEventList) return false
      return !this.courseList || Object.keys(this.courseList).length == 0
    }
  },
  components: {
    EventItem: require('./event_item'),
    CourseItem: require('./course_item')
  }
}
</script>

<style lang="scss" scoped>
@import "../../css/config";
.components-index_list-index{
  width: 100%;
  box-sizing: border-box;
  padding: 25px 25px 25px+$tablist-height 25px;
  .topline{
    width: 100%;
    height: 1px;
    margin-bottom: 20px;
    background-color: #50291a;
  }
  .eventDetail-header, .courseBlock-header{
    width: 100%;
    padding-bottom: 15px;
    span{
      display: inline-block;
      font-size: 24px;
      color: #fff;
      line-height: 1.2;
      padding-right: 15px;
    }
  }
  .eventNotice{
    width: 100%;
    height: 280px;
    border-radius: 21px;
    color: #fff;
    font-size: 60px;
    font-weight: bold;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    box-sizing: border-box;
    padding: 30px 0;
    span{
      display: block;
    }
  }
  .courseNotice{
    position: relative;
    width: 100%;
    height: 95px;
    box-sizing: border-box;
    padding: 13px 20px 13px 85px;
    color: #fff;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    .text-left{
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: flex-start;
      font-weight: 100;
      .subtext{
        display: block;
        line-height: 1.2;
        font-size: 25px;
      }
      .maintext{
        display: block;
        line-height: 1.2;
        font-size: 25px;
        color: #e2e2e2;
      }
    }
    .text-right{
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-end;
      font-weight: bold;
      font-size: 48px;
      color: #e2e2e2;
      letter-spacing: 1Px;
    }
    .icon-time{
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      left: 20px;
      display: block;
      width: 55px;
      height: 55px;
      background-color: transparent;
      background: url('../../assets/image/time.png') no-repeat center;
      background-size: cover;
    }
  }
  // padding: 25px 25px 0;
}
</style>
